import {lazy} from "react"
import {Navigate} from "react-router-dom"
const Login = lazy(()=>import("../pages/Login"))
const Home = lazy(()=>import("../pages/Index/Home"))
const Achievement = lazy(()=>import("../pages/Index/achievement"))
const Test = lazy(()=>import("../pages/Index/test"))
const Testpaper = lazy(()=>import("../pages/Index/testPaper"))
const Testpaper1 = lazy(()=>import("../pages/tsetpaper/testpaper1"))
const Testpaper2 = lazy(()=>import("../pages/tsetpaper/testpaper2"))
const Notfind = lazy(()=>import("../pages/notFind"))

export const adminChild = [
    {
        path:"/home/testpaper",
        element:<Testpaper></Testpaper>,
        tit:"试卷管理",
        children:[
            {
                path:"/home/testpaper/testpaper1",
                element:<Testpaper1></Testpaper1>,
                tit:"试卷管理"
            },
            {
                path:"/home/testpaper/testpaper2",
                element:<Testpaper2></Testpaper2>,
                tit:"试卷管理"
            },
        ]
    },
    {
        path:"/home/test",
        element:<Test></Test>,
        tit:"试题管理"
    },
    {
        path:"/home/achievement",
        element:<Achievement></Achievement>,
        tit:"成绩管理"
    }



]
export const userChild = [
    {
        path:"/home/testpaper",
        element:<Testpaper></Testpaper>,
        tit:"试卷管理",
        children:[
            {
                path:"/home/testpaper/testpaper1",
                element:<Testpaper1></Testpaper1>,
                tit:"试卷管理"
            },
        ]
    },
    {
        path:"/home/test",
        element:<Test></Test>,
        tit:"试题管理"
    },
    {
        path:"/home/achievement",
        element:<Achievement></Achievement>,
        tit:"成绩管理"
    }
]



const routerconfig = [
    {
        path:"/login",
        element:<Login></Login>
    },
    {
        path:"/home",
        element:<Home></Home>,
        children:localStorage.getItem("user")==="admin"?adminChild:userChild
    },
    {
        path:'/',
        element:<Navigate to="/login"></Navigate>
    },
    {
        path:"*",
        element:<Notfind></Notfind>
    }
]
export default routerconfig